<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/11/7
  Time: 15:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/mb/jsp/common.jsp" %>

<%@ page import="com.limao.servlet.WebFunction" %>
<%@ page import="com.limao.DBDataClass.CrowdUserAuthClass" %>

<%
    String userid=CacheClass.isLogin(request,response);
    if (CacheClass.getIntValue(userid) == 0) {
        out.println("<script language='JavaScript'>alert('您还没有登陆！');location.href=document.referrer;</script>"); //后退并刷新
        return;
    }
    CrowdUserAuthClass user = WebFunction.getUserInfo(request, response);
    if (user == null) {
        out.println("<script language='JavaScript'>alert('用户不存在，或被平台禁用，请联系客服！');window.history.back(-1);</script>");
        return;
    }
%>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>提现申请</title>
     <script src="js/validation/jquery.validate.js"></script>
    <script src="js/validation/messages_zh.js"></script>
</head>
<body ontouchstart="">
<div class="detailTop pf w100 of">
    <div class="w100 of tc cf  flexBox pr">
      <span class="pa" style="left: 2px;" onclick="javascript:history.back();"><img src="mb/images/top_back_white.png"
                                                                                      style="margin-top: 4px;height: 40px;width: 40px;"/></span>
     	<a href="javascript:history.back();" class="db f14 tl pr" style="margin-left: 4%;width:19%;">
     		
        </a>
      	<p class="f18 tc" style="width:54%;">   提现申请</p>
       <a href="mb/jsp/withdrawRecord.jsp" class="db of f14 tr" style="margin-right: 4%;width:19%;">
           		提现记录
        </a>
    </div>
</div>

<div class="container db jz mgt45 of" style="padding-bottom: 0;">
  <form  method="post" id="signupForm" action="" style="margin-bottom: 60px;" class="of">
  
    <section class="proSection pr w100 bcf withdrawBack">
        <div class="drawMoney of  mgb32">
            <p class="cf f20 tc lh18 mgt10" style="margin-bottom: 2px;">余额</p>
            <p class="bcf jz" style="height:3px;width:25px;"></p>
            <p id="allMoney" class="cf tc f20 mgt10" style="margin-bottom: 2px;"><%=user.nowrmb %>
            </p>
        </div>
        <div class="pa w100" style="bottom:-28px;left:0">
        	<div class="w92 jz of bcf">
        		<div class="df"  style="padding:8px;">
        			<img alt="" src="mb/images/info_orange.png" class="db wauto" style="height:16px;margin-top: 2px;">
        			<p class="orange2 f12 mgl10" >7个工作日内最多提现２次，每次提现金额为可用金额的40.0%</p>
        		</div>
        	</div>
       </div>
    </section>
    
     <div class="withDrawForm db w100 of bcf">
     	<section class="flexBox b-b jz">
     		<img src="mb/images/with1.png">
     		<lable class="db c3 mgl10" for="moneyCash">提现金额:</lable>
     	 	<input type="text"  name="moneyCash" id="moneyCash" placeholder="请输入提现金额" required="required" onkeyup="this.value=(this.value.match(/\d+(\.\d{0,2})?/)||[''])[0]"/>
     	</section>
     	
     	<section class="flexBox b-b jz">
     		<img src="mb/images/with2.png">
     		<lable class="db c3 mgl10" for="moneyCash">银行卡号:</lable>
     	 	<input type="text" name="bankCard" placeholder="请输入银行卡号" id="bankCard" required="required"   onkeyup="value=value.replace(/[^\d]/g,'') "   
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
		</section>
       
       
        <section class="flexBox b-b jz">
     		<img src="mb/images/with3.png">
     		<lable class="db c3 mgl10" for="moneyCash">银行卡户名:</lable>
     	 	<input type="text" name="bankCardName" placeholder="请输入银行卡户名" id="bankCardName" required="required"/>
     	</section>
     	
     	 <section class="flexBox b-b jz">
     		<img src="mb/images/with4.png">
     		<lable class="db c3 mgl10" for="moneyCash">银行卡开户行及支行:</lable>
     	 	 <input type="text" name="openingBank" placeholder="银行卡开户行及支行" id="openingBank" required="required"/>
     	</section>
        
        
         <section class="flexBox b-b jz">
     		<img src="mb/images/with5.png">
     		<lable class="db c3 mgl10" for="moneyCash">银行卡开户地(市级):</lable>
     	 	<input type="text" name="openingBankPlace" id="openingBankPlace" placeholder="市级（如：武汉市）" required="required"/>
     	</section>
        
        <section class="flexBox b-b jz">
     		<img src="mb/images/with6.png">
     		<lable class="db c3 mgl10" for="moneyCash">App登陆密码:</lable>
     	 	 <input type="password" name="" placeholder="请输入App登陆密码" id="apppwd" required="required"/>
     	</section>
       
       
    </div>

    <div class="detailBottm pf w100 of">
        <button type="button" class="db w100 f18 cf f18 tc btnBlue" id="withdrawSub" onclick="Sub();">确定提现</button>
    </div>
	</form>
</div>
<script>
 var myValidator;
$().ready(function() {
         var allMoney = $("#allMoney").text();
         var moneyLimit = (allMoney*0.4).toFixed(2);
	 	  myValidator=$("#signupForm").validate(
	 		{
	 			rules:{
	 				bankCard:{
	 					required: true,
	 					number:true,
                		rangelength:[16,19] 
  	 				},
	 				moneyCash:{
	 					required: true,
	 					number:true,
	 					min:1,
	 					max:moneyLimit
  	 				},
            		apppwd:
            		{
            			required:true,
            			rangelength:[6,20]
            		},
	 				bankCardName:
            		{
            			required:true,
            			rangelength:[2,10]
	 				},
	 				openingBank:
            		{
            			required:true,
            			minlength:2
	 				},
	 				openingBankPlace:
            		{
            			required:true,
            			minlength:2
	 				}
	 				
	 			},
	 			//errorElement: 'p',
                errorPlacement: function(error, element) {
                // Append error within linked label
	                $( element )
		                .closest( "form" )
		                .find( element )
		                .parent()
		                .after( error);
	                },
	                errorElement: "p",
	                errorClass:"errorInfo",
		 		});
});



    function Sub(){
     	if(myValidator.form()== false){
             showToast("填写存在错误!");
            return false;
        }
    
    	 var money = $.trim($('#moneyCash').val());
            var bankCard = $.trim($('#bankCard').val());
            var bankCardName = $.trim($('#bankCardName').val());
            var openingBank = $.trim($('#openingBank').val());
            var openingBankPlace = $.trim($('#openingBankPlace').val());
            var apppwd = $.trim($('#apppwd').val());

            if (money == "") {
                showToast("你还未填写金额");
                return false;
            }

            if (bankCard == "") {
                showToast("你还未填写银行卡号!");
                return false;
            }
            
            if (bankCardName == "") {
                showToast("你还未填写银行卡户名!");
                return false;
            }
            
            if (openingBank == "") {
                showToast("你还未填写银行卡开户行!");
                return false;
            }

            if (apppwd == "") {
                showToast("请输入app登陆密码!");
                return false;
            }
            $.ajax({
                url: "PlugServlet",
                data: JSON.stringify({
                    m: 215,
                    rmb: money,
                    password: $.md5(apppwd),
                    cardtype: "0",
                    cardno: bankCard,
                    cardname: bankCardName,
                    cardbank: openingBank,
                    cardarea: openingBankPlace
                }),
                type: 'post',
                dataType: 'json',
                beforeSend: function () {
                    showProgressDg();
                   
                },
                success: function (data) {
                    if (data.state == 1) {
                        showTipDialog("提示", "申请提交成功，工作人员二个工作日内审核！", completeW, 1);
                    } else {
                        showToast(data.info);
                    }
                },
                error: function (data) {
                    showToast(data.info);
                    return false;
                },
                complete: function () {
                    closeProgressDg();
                }
            });
    }

    var completeW = function completeWithdraw() {
        // 关闭当前页面回到前一页
        javascript:history.back();
    }

</script>
</body>
</html>
